package org.gruposp2p.proyectokarma.domain;

import static javax.persistence.GenerationType.IDENTITY;

import java.util.Date;
import java.util.UUID;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import org.hibernate.search.annotations.DateBridge;
import org.hibernate.search.annotations.DocumentId;
import org.hibernate.search.annotations.Resolution;

@Entity
@Table(name="RegistrationCode")
public class RegistrationCode implements java.io.Serializable {

	private static final long serialVersionUID = 1L;
	
	@Id @GeneratedValue(strategy=IDENTITY)
    @Column(name="id", unique=true, nullable=false)
    @DocumentId
    private Long id;
    @Column(name="username", nullable=false)
	private	String username;
    @Column(name="token", nullable=false)
	private	String token;
    @DateBridge( resolution = Resolution.DAY )
    @Temporal(TemporalType.TIMESTAMP)
    @Column(name="dateCreated", length=23)
	private	Date dateCreated;
    

	public RegistrationCode () {
		token = UUID.randomUUID().toString().replaceAll("-", "");
	}
	
	public void setId(Long id) {
		this.id = id;
	}

	public Long getId() {
		return id;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getUsername() {
		return username;
	}

	public void setToken(String token) {
		this.token = token;
	}

	public String getToken() {
		return token;
	}

	public void setDateCreated(Date dateCreated) {
		this.dateCreated = dateCreated;
	}

	public Date getDateCreated() {
		return dateCreated;
	}

}
